package jl.security;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 江黎
 * @date 2022-02-07
 */
@SpringBootApplication
@RestController
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

    @GetMapping("/userInfo")
    public Object getUserInfo(Authentication authentication) {
        return authentication;
    }
    @GetMapping("/userInfo1")
    public Object getUserInfo1(@AuthenticationPrincipal UserDetails userDetails) {
        return userDetails;
    }
}
